package com.jxpanda.infrastructure.crypto.key;

import com.jxpanda.infrastructure.crypto.constant.AlgorithmEncrypt;
import com.jxpanda.infrastructure.crypto.key.contract.AbstractKeyProvider;
import com.jxpanda.infrastructure.crypto.key.contract.KeyPairProvider;

import java.security.KeyPair;
import java.security.spec.ECGenParameterSpec;

public class EcKeyPairProvider extends AbstractKeyProvider<KeyPair, ECGenParameterSpec> implements KeyPairProvider<ECGenParameterSpec> {


    public EcKeyPairProvider() {
        super(AlgorithmEncrypt.EC.KEY_ALGORITHM);
    }

    @Override
    public KeyPair generateKey() {
        return generateKey(createAlgorithmParameterSpec());
    }

    public static ECGenParameterSpec createAlgorithmParameterSpec() {
        return createAlgorithmParameterSpec(AlgorithmEncrypt.EC.CURVE_SECP_256_R1);
    }

    public static ECGenParameterSpec createAlgorithmParameterSpec(String curveName) {
        return new ECGenParameterSpec(curveName);
    }


}
